import signal

from app import create_app
from configs import config
from start import close, TCPServer, tcp_start, ThreadTCPHandler


if __name__ == "__main__":

    signal.signal(signal.SIGINT, close)
    signal.signal(signal.SIGTERM, close)

    server = TCPServer((config.SERVER_HOST, config.SERVER_PORT), ThreadTCPHandler)
    tcp_start(server)

    app = create_app()
    app.run(host=app.config['SERVER_HOST'])

